home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / tex / mf / rexx / namestruc < prev    next >
Text File  |  1993-09-29  |  803b  |  27 lines

  1. /*
  2. ** AREXX $VER: NameStruc V1.0 (13.09.1992)
  3. **
  4. ** This ARexx script accepts a filename and returns three lengthes (not
  5. ** strings, to avoid problems with embedded spaces) corresponding to the
  6. ** main parts of this filename.
  7. **
  8. ** Example: RAM:foo/bar/nasty.tar.Z
  9. **          ^   ^       ^
  10. **      volume   : 4 (RAM:)
  11. **      subdirlen: 8 (foo/bar/)  NOTE : The trailing slash is included.
  12. **      baselen  : 9 (nasty.tar) NOTE : if no extension, whole length.
  13. */
  14. Parse Arg FULLNAME /* FULLNAME = strip(FULLNAME,'L') */
  15.  
  16. VOLUME    = Index(FULLNAME,":")
  17. SUBDIRLEN = LastPos("/",SubStr(FULLNAME,1+VOLUME))
  18. FILEONLY  = SubStr(FULLNAME,VOLUME+1+SUBDIRLEN)
  19. BASELEN   = LastPos(".",FILEONLY)
  20.  
  21. If 0 = BASELEN Then
  22.   BASELEN = Length(FILEONLY)
  23. Else
  24.   BASELEN = BASELEN - 1
  25.  
  26. Return VOLUME' 'SUBDIRLEN' 'BASELEN
  27.